* May 9, 2025
version 19.5

*************
* Prep Data *
*************

* We obtained prolific_survey.rds from https://doi.org/10.7910/DVN/9JWDKK
* and exported it as a CSV, which we load into Stata here
import delimited using "../data/prolific_survey.csv", varnames(1) asdouble clear
keep nukes_regime nukes_race nukes_strike ethno_bizumic_factor

*************************************************
* Construct treatment indicators and moderators *
*************************************************

* Independent variable: democracy treatment
gen byte t_democ = cond(nukes_regime == "dem", 1, 0)
label var t_democ "Country Regime"
label define t_democ 0 "Country is not a Democracy" 1 "Country is a Democracy"
label values t_democ t_democ
drop nukes_regime

* Independent variable: race treatment
gen byte t_race = 0 // race of target country. initialize as 0 = not mentioned
replace t_race = 1 if nukes_race == "white"
replace t_race = 2 if nukes_race == "nonwhite"
label var t_race "Country Race"
label define t_race 0 "Unspecified" 1 "Country Race is White" 2 "Country Race is Nonwhite"
label values t_race t_race
drop nukes_race

* Dependent variable: support for strike
rename nukes_strike strike
tab strike, miss

* Moderator: ethnocentrism
su ethno_bizumic_factor, det
gen ethno_hi = cond(ethno_bizumic_factor > `r(p50)', 1, 0) if ethno_bizumic_factor ~= .

***********
* Analyze *
***********

log using ../output/test34.txt, text nomsg replace

* Table 5: Effect of Democracy, By Whether Race Was Specified as White or Nonwhite
regress strike t_democ##t_race if inlist(t_race,0,2), robust // column 3
etable, column(estimates) cstat(_r_b, nformat(%5.2f)) ///
   cstat(_r_se, nformat(%5.2f)) mstat(N) showstars showstarsnote ///
   export(../output/Table5.3.xlsx, replace)

* Supp 2.2: Does Ethnocentrism Moderate the Eliminated Effect?
regress strike t_democ##t_race##ethno_hi, robust // if race is nonwhite
etable, column(estimates) cstat(_r_b, nformat(%5.2f)) ///
   cstat(_r_se, nformat(%5.2f)) mstat(N) showstars showstarsnote ///
   export(../output/Supp2.2.xlsx, replace)

log close